//
//  ShoppingCarHeaderOne.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/17.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class ShoppingCarHeaderOne: BaseTableHeaderFooterView {
    
    @IBOutlet weak var seletBtn: UIButton!
    
    
    @IBOutlet weak var rightLabel: UILabel!
    weak var delegate : ShoppingCarCellDelegate?{
        
        didSet{
            
            if delegate == nil {
                return
            }
            
            self.VC = delegate as? ShoppingCarController
            
        }
        
    }
    
    weak var VC : ShoppingCarController?


      
    var model : ShopCartListModel?{
    
    
        didSet{
        
            if model == nil {
                return
            }
        
            rightLabel.text = model?.store_name
            
            seletBtn.isSelected = model!.isSelect
          

        }
    
    
    }
    
    
    

    @IBAction func leftBtnDidTap(_ sender: UIButton) {
        
        sender.isSelected = !sender.isSelected
        model?.isSelect = sender.isSelected
        
         for item in model!.goods {
         
           item.isSelect = model!.isSelect
            
        }
        
        VC?.calculateTotalPrice()
        
        VC?.plainTableView.reloadData()
        
        
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        seletBtn.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10)
        
        rightLabel.font = UIFont.systemFont(ofSize: 16)
        
    }
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        
    }
    
    
    

}
